home *** CD-ROM | disk | FTP | other *** search
/ Hottest 6 / Hottest 6 (1996)(PDSoft)[!].iso / software / videoutils / a-g / fixobj / fixvobj.e < prev    next >
Text File  |  1978-11-24  |  2KB  |  65 lines

  1. /* FixVObj.e      Swaps the signs of Z coords, so the objects will
  2.          look the same as Wavefront in Imagine and Vertex
  3.                                   */
  4.  
  5. DEF pos[500]: STRING,ok,strcount,eof=-1
  6. DEF handle=NIL
  7.  
  8. PROC main()
  9.    IF StrCmp(arg,'',1) OR StrCmp(arg,'?',2) THEN usage()
  10.    handle:=Open(arg,OLDFILE)
  11.    IF handle=NIL THEN error()
  12.    WriteF('# Vertex Wavefront file with flipped Z coords\n')
  13.    fix()
  14.    error()
  15. ENDPROC
  16.  
  17. PROC error()                                 /* eof or bad file */
  18.    IF handle THEN Close(handle)
  19.    CleanUp(0)
  20. ENDPROC
  21.  
  22. PROC fix()
  23. /*     This procedure makes the actual corrections to the file   */
  24.  
  25. DEF vertex=FALSE,counter
  26.  
  27.    ok:=ReadStr(handle, pos)
  28.    IF ok=eof THEN error()
  29.    REPEAT
  30.       strcount:=EstrLen(pos)
  31.       IF CtrlC() THEN error()
  32.  
  33.       IF pos[0]=$76 THEN vertex:=TRUE
  34.      IF vertex                 /* change only vertex lines */
  35.         REPEAT
  36.            DEC strcount
  37.         UNTIL pos[strcount]=$20
  38.         INC strcount
  39.         IF pos[strcount]=$2d         /* change '-' to a space */
  40.            pos[strcount]:=$20
  41.         ELSE                 /* insert a '-' */
  42.            counter:=EstrLen(pos)
  43.            INC counter
  44.            SetStr(pos,counter)
  45.            REPEAT
  46.           pos[counter]:=pos[counter-1]
  47.           counter--
  48.            UNTIL counter=strcount
  49.            pos[strcount]:=$2d
  50.         ENDIF
  51.         vertex:=FALSE
  52.      ENDIF
  53.       WriteF('\s\n', pos)
  54.       ok:=ReadStr(handle, pos)
  55.    UNTIL ok=eof
  56. ENDPROC
  57.  
  58. PROC usage()
  59.    WriteF('FixVObj 1.0  : Flips sign of in/out plane of Wavefront files\n')
  60.    WriteF('               For use with Vertex\n')
  61.    WriteF('\nUsage :  FixVObj <file>\n\nOutput can be redirected to a file\n')
  62.    WriteF('\n(c) 1993 Danimal\n')
  63.    error()
  64. ENDPROC
  65.